﻿

var g_str_type_1 = "clothing";
var g_str_type_3 = ""; 
var g_str_sex = "0"; 
var g_bool_init_finish = false;


//-------------页面初始化--------------
function initPage()
{
	DisplayObj("btn_edit_all_dress_order_index", "none"); //隐藏修改所有套装排序字段按钮
    GetListType_1();  		//查找一级类
}

//-------------查找分类--------------
function GetListType_1()
{  
	on_select_change_type2()
} 

function on_select_change_type2()
{  
	tmpTypeVal_1 = "clothing";      	    //当前选择类别1
	tmpTypeVal = "";      					//当前选择类别2
	var data = "&typeName_1=" + tmpTypeVal_1;
	data += "&typeName=" + tmpTypeVal;
	PostToPHP(__on_select_change_type2_callback, "info", "query_type_3", data); 
}
function __on_select_change_type2_callback(text)
{
	//alert(text);
	var jsonObj = String2JSON(text);
	var ds = GetDataSet(jsonObj);
	if(ds && ds[0])
	{
        FillSelectObj("type_3", ds[0]);	
		g_bool_init_finish = true;		//初始化成功
	}
} 

//-------------查询-----------
function on_query()
{ 
	if(!g_bool_init_finish)
		return;
		  
	g_str_type_3 = $("type_3").value;   	//当前三级类
	g_str_sex = $("select_gender").value;   //当前选择查询的性别
	
	CleanConfig(); //清空配置  
        
	 
	AddItemConfig("id", 0);   
	AddItemConfig("sex", 98, JudgeIsSexTextFunc);
	AddItemConfig("level", 0);
	AddItemConfig("type_3", 0);  
	
	AddItemConfig("is_sell", 98, JudgeIsSellTextFunc);
	AddItemConfig("is_new", 98, JudgeIsNewTextFunc); 
	
	AddItemConfig("cost_goods_id", 0);  
	AddItemConfig("cost_goods_name", 0);  
	AddItemConfig("cost_goods_name_view", 0); 
	
	AddItemConfig("trousers_goods_id", 0);  
	AddItemConfig("trousers_goods_name", 0);  
	AddItemConfig("trousers_goods_name_view", 0);  
	
	AddItemConfig("skirt_goods_id", 0);  
	AddItemConfig("skirt_goods_name", 0);  
	AddItemConfig("skirt_goods_name_view", 0);  
	
	AddItemConfig("coat_goods_id", 0);  
	AddItemConfig("coat_goods_name", 0);  
	AddItemConfig("coat_goods_name_view", 0);  
	
	AddItemConfig("id", 99, "../edit/goods_dress_edit.html?id=", "编辑");
	AddItemConfig("id", 2, "deleteFunc", "删除");
	AddItemConfig("id", 2, "editIsSellFunc", "设置可售"); 
	AddItemConfig("id", 2, "editIsNewFunc", "设置新旧");  
	
	var _data_1 = "&type_1=" + g_str_type_1;  
		_data_1 += "&type_3=" + g_str_type_3; 
		_data_1 += "&sex=" + g_str_sex;   
	
	SetPagingConfig("paging", "get_goods_dress_total", _data_1, 
					"paging", "get_goods_dress_list", _data_1);
					
	PagingInit(GetDefaultPageCount(), "tbody_query", "div_paging");            
}

//--删除
function deleteFunc(index, id)
{ 
	alert("不允许删除");
	return;
	if(confirm("是否删除?") == false) return;
	
	var data = "&id=" + id; 
	PostToPHP(__deleteFuncCallback, "info", "delete_goods_dress", data);
}
function __deleteFuncCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, RePaging);
}

function JudgeIsSexTextFunc(index, val) //男女 0:女， 1:男
{
	return val == 0 ? "女" : "男";
}
function JudgeIsSellTextFunc(index, val) //是否可售(0为不可售 1:可售
{
	return val == 0 ? "停售" : "在售";
}
function JudgeIsNewTextFunc(index, val) //是否新品(0为新 1:旧)
{
	return val == 0 ? "新" : "旧";
}

//---设置新旧
function editIsNewFunc(index, id)
{ 
	//if(confirm("是否设置新旧?") == false) return;	
	var data = "&id=" + id; 
	PostToPHP(__editNoSellFuncCallback, "info", "set_goods_dress_is_new", data);
}
//---设置可售
function editIsSellFunc(index, id)
{ 
	//if(confirm("是否设置可售?") == false) return;	
	var data = "&id=" + id; 
	PostToPHP(__editNoSellFuncCallback, "info", "set_goods_dress_is_sell", data);
} 
function __editNoSellFuncCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, RePaging);
}

//编辑所有套装排序字段
function on_edit_all_dress_order_index()
{
	PostToPHP(__on_edit_all_dress_order_indexCallback, "info", "edit_all_dress_order_index", "");
}
function __on_edit_all_dress_order_indexCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, null);
}
